import Cookies from 'js-cookie'

const TokenKey = 'Admin-Token'

export function getToken() {
  return Cookies.get(TokenKey)
}

export function setToken(token) {
  return Cookies.set(TokenKey, token)
}

export function removeToken() {
  return Cookies.remove(TokenKey)
}

const UserInfoKey = 'loginUser'
export function getLoginUser() {
  const user = Cookies.get(UserInfoKey)
  return user ? JSON.parse(Cookies.get(UserInfoKey)):null
}

export function setLoginUser(user) {
  return Cookies.set(UserInfoKey, JSON.stringify(user))
}

export function removeLoginUser() {
  return Cookies.remove(UserInfoKey)
}
export function removeCathe() {
  return Cookies.remove(UserInfoKey) && Cookies.remove(UserInfoKey)
}
